	//=============================================================================
// SRKFPawn
//=============================================================================
class SRKFHumanPawn extends KFHumanPawn;

var float weldingValue;
var vector AFKLocation;
var float AFKTimer;
//var() config string	RequiredEquipment[16];

/* function AddDefaultInventory()
{
	local int i;

	if ( KFSPGameType(Level.Game) != none )
	{
		Level.Game.AddGameSpecificInventory(self);

		if ( Inventory != none )
			Inventory.OwnerEvent('LoadOut');

		return;
	}

	if ( IsLocallyControlled() )
	{
		for ( i = 0; i < 16; i++ )
			if ( RequiredEquipment[i] != "" )
				CreateInventory(RequiredEquipment[i]);

		if ( KFPlayerReplicationInfo(PlayerReplicationInfo) != none && KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none )
		{
			KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill.static.AddDefaultInventory(KFPlayerReplicationInfo(PlayerReplicationInfo), self);
		}

		for ( i = 0; i < 16; i++ )
			if ( (SelectedEquipment[i] == 1) && (OptionalEquipment[i] != "") )
				CreateInventory(OptionalEquipment[i]);

		Level.Game.AddGameSpecificInventory(self);
	}
	else
	{
		Level.Game.AddGameSpecificInventory(self);

		for ( i = 15; i >= 0; i-- )
			if ( (SelectedEquipment[i] == 1) && (OptionalEquipment[i] != "") )
				CreateInventory(OptionalEquipment[i]);

		if ( KFPlayerReplicationInfo(PlayerReplicationInfo) != none && KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none )
		{
			KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill.static.AddDefaultInventory(KFPlayerReplicationInfo(PlayerReplicationInfo), self);
		}

		for ( i = 15; i >= 0; i-- )
			if ( RequiredEquipment[i] != "" )
				CreateInventory(RequiredEquipment[i]);
	}

	if ( Inventory != None )
		Inventory.OwnerEvent('LoadOut');

	Controller.ClientSwitchToBestWeapon();
} */

/*
simulated exec function QuickHeal()
{
	local SyringeW S;
	local Inventory I;
	local byte C;
	//Log("QuickS");
	if ( Health>=HealthMax )
		return;
	for( I=Inventory; (I!=None && C++<250); I=I.Inventory )
	{
		S = SyringeW(I);
		if( S!=None )
			break;
	}
	if ( S == none )
		return;

	if ( S.ChargeBar() < 0.95 )
	{
		if ( 	PlayerController(Controller) != none && 
				HUDKillingFloor(PlayerController(Controller).myHud) != none )
		{
			HUDKillingFloor(PlayerController(Controller).myHud).ShowQuickSyringe();
		}

		return; // No can heal.
	}

	bIsQuickHealing = 1;
	if ( Weapon==None )
	{
		PendingWeapon = S;
		ChangedWeapon();
	}
	else if ( Weapon!=S )
	{
		PendingWeapon = S;
		Weapon.PutDown();
	}
	else // Syringe already selected, just start healing.
	{
		bIsQuickHealing = 0;
		S.HackClientStartFire();
	}
}*/

/*
function GiveWeapon(string aClassName )
{
	local class<Weapon> WeaponClass;
	local Weapon NewWeapon;
	//Log("SRKFHumanPawn.GiveWeapon");
	WeaponClass = class<Weapon>(DynamicLoadObject(aClassName, class'Class'));

	if( FindInventoryType(WeaponClass) != None )
		return;
	//Log("SRKFHumanPawn.GiveWeapon Alive?");
	newWeapon = Spawn(WeaponClass);
	if( newWeapon != None )
		newWeapon.GiveTo(self);
}

function CreateInventoryVeterancy(string InventoryClassName, float SellValueScale)
{
	local Inventory Inv;
	local class<Inventory> InventoryClass;
	//Log("CreateInventoryVeterancy Adv"@Level.Game.BaseMutator@InventoryClassName);
	InventoryClass = Level.Game.BaseMutator.GetInventoryClass(InventoryClassName);
	//Log("InventoryClass="$InventoryClass);
	if( (InventoryClass!=None) && (FindInventoryType(InventoryClass)==None) )
	{
		Inv = Spawn(InventoryClass);
		if( Inv != none )
		{
			SRKFWeapon(Inv).GiveTo(self);
			if ( Inv != none )
				Inv.PickupFunction(self);

			if ( SRKFWeapon(Inv) != none )
			{
				SRKFWeapon(Inv).SellValue = float(class<SRKFWeaponPickup>(InventoryClass.default.PickupClass).default.Cost) * SellValueScale * 0.75;
			}
		}
	}
}
 */
function bool WeldArmor(float value)
{
	local int intValue;
	local KFPlayerReplicationInfo KFPRI;
	KFPRI = KFPlayerReplicationInfo(PlayerReplicationInfo);

	weldingValue += value;
	intValue = int(weldingValue);
	if(intValue>0)
	{
		ShieldStrength += intValue;
		if (KFPRI != none)
		{
			if ( (	KFPRI.ClientVeteranSkill == Class'SRVetFirebug' && KFPRI.ClientVeteranSkillLevel > 8) ||
					KFPRI.ClientVeteranSkillLevel > 12 )
			{
				if(ShieldStrength > 150)
					ShieldStrength = 150;
			}
			else
			{
				if(ShieldStrength > 100)
					ShieldStrength = 100;
			}
		}
		weldingValue -= intValue;
		return True;
	}
	return False;
}
// Just changed to pendingWeapon
simulated function ChangedWeapon()
{
	local class<SRVeterancyTypes> CurrentPlayerVeterancy;
	local float tmpExtendedSpeedIncrease;
	//Log("SRKFHumanPawn.ChangedWeapon");
	Super(KFPawn).ChangedWeapon();
		/* Advanced speed modifier extension - BAKAP */
	if (KFPlayerReplicationInfo(PlayerReplicationInfo) != none && 
		KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none 
		)
		CurrentPlayerVeterancy = class<SRVeterancyTypes>(KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill);
	if ( Weapon != none && CurrentPlayerVeterancy != none)
	{
		tmpExtendedSpeedIncrease = CurrentPlayerVeterancy.static.GetMovementSpeedModifierEx(KFPlayerReplicationInfo(PlayerReplicationInfo), KFWeapon(Weapon), ShieldStrength ,Health, False);
		if (tmpExtendedSpeedIncrease != 1.0)
		{
			if (KFWeapon(Weapon).bSpeedMeUp)
				tmpExtendedSpeedIncrease += default.BaseMeleeIncrease;
			if (tmpExtendedSpeedIncrease > 1)
			{
				InventorySpeedModifier = (default.GroundSpeed * (tmpExtendedSpeedIncrease - 1));
				if (KFWeapon(Weapon).bSpeedMeUp)
					InventorySpeedModifier -= (KFWeapon(Weapon).Weight * 2);
			}
			else if (tmpExtendedSpeedIncrease < 1)
			{
				InventorySpeedModifier = -(default.GroundSpeed * (1 - tmpExtendedSpeedIncrease));
				if (KFWeapon(Weapon).bSpeedMeUp)
					InventorySpeedModifier -= (KFWeapon(Weapon).Weight * 2);
			}
			else
			{
				if (KFWeapon(Weapon).bSpeedMeUp)
					InventorySpeedModifier -= (KFWeapon(Weapon).Weight * 2);
			}
			return;
		}
	}
	// Experience Level relate stuff .
	if ( Weapon != none && KFWeapon(Weapon).bSpeedMeUp )
	{
		// Adjust Melee weapon speed bonuses depending on perk.
		BaseMeleeIncrease = default.BaseMeleeIncrease;
		if (	KFPlayerReplicationInfo(PlayerReplicationInfo) != none && 
				KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none )
		{
			BaseMeleeIncrease += KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill.Static.GetMeleeMovementSpeedModifier(KFPlayerReplicationInfo(PlayerReplicationInfo));
		}
		InventorySpeedModifier = ((default.GroundSpeed * BaseMeleeIncrease) - (KFWeapon(Weapon).Weight * 2));
	}
	else if ( Weapon == none || !KFWeapon(Weapon).bSpeedMeUp )
	{
		InventorySpeedModifier = 0;
	}
}

function ServerChangedWeapon(Weapon OldWeapon, Weapon NewWeapon)
{
	local class<SRVeterancyTypes> CurrentPlayerVeterancy;
	local float tmpExtendedSpeedIncrease;
	//Log("SRKFHumanPawn.ChangedWeapon");
	Super(KFPawn).ServerChangedWeapon(OldWeapon,NewWeapon);
	/* Advanced speed modifier extension - BAKAP */
	if (KFPlayerReplicationInfo(PlayerReplicationInfo) != none && 
		KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none 
		)
		CurrentPlayerVeterancy = class<SRVeterancyTypes>(KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill);
	if ( Weapon != none && CurrentPlayerVeterancy != none)
	{
		tmpExtendedSpeedIncrease = CurrentPlayerVeterancy.static.GetMovementSpeedModifierEx(KFPlayerReplicationInfo(PlayerReplicationInfo), KFWeapon(Weapon), ShieldStrength ,Health, False);
		if (tmpExtendedSpeedIncrease != 1.0)
		{
			if (KFWeapon(Weapon).bSpeedMeUp)
				tmpExtendedSpeedIncrease += default.BaseMeleeIncrease;
			if (tmpExtendedSpeedIncrease > 1)
			{
				InventorySpeedModifier = (default.GroundSpeed * (tmpExtendedSpeedIncrease - 1));
				if (KFWeapon(Weapon).bSpeedMeUp)
					InventorySpeedModifier -= (KFWeapon(Weapon).Weight * 2);
			}
			else if (tmpExtendedSpeedIncrease < 1)
			{
				InventorySpeedModifier = -(default.GroundSpeed * (1 - tmpExtendedSpeedIncrease));
				if (KFWeapon(Weapon).bSpeedMeUp)
					InventorySpeedModifier -= (KFWeapon(Weapon).Weight * 2);
			}
			else
			{
				if (KFWeapon(Weapon).bSpeedMeUp)
					InventorySpeedModifier -= (KFWeapon(Weapon).Weight * 2);
			}
			return;
		}
	}
		// Experience Level relate stuff .
	if( Weapon!= none && KFWeapon(Weapon).bSpeedMeUp )
	{
		// Adjust Melee weapon speed bonuses depending on perk.
		BaseMeleeIncrease = default.BaseMeleeIncrease;
		if ( CurrentPlayerVeterancy != none )
		{
			BaseMeleeIncrease += CurrentPlayerVeterancy.Static.GetMeleeMovementSpeedModifier(KFPlayerReplicationInfo(PlayerReplicationInfo));
		}
		InventorySpeedModifier = ((default.GroundSpeed * BaseMeleeIncrease) - (KFWeapon(Weapon).Weight * 2));
	}
	else if (Weapon == none || !KfWeapon(Weapon).bSpeedMeUp)
	{
		InventorySpeedModifier = 0;
	}
}

simulated event ModifyVelocity(float DeltaTime, vector OldVelocity)
{
	local float WeightMod, HealthMod;
	local float EncumbrancePercentage;
	Super(KFPawn).ModifyVelocity(DeltaTime, OldVelocity);

	if (Controller != none)
	{
		// Calculate encumbrance, but cap it to the maxcarryweight so when we use dev weapon cheats we don't move mega slow
		EncumbrancePercentage = (FMin(CurrentWeight, MaxCarryWeight)/MaxCarryWeight);
		// Calculate the weight modifier to speed
		WeightMod = (1.0 - (EncumbrancePercentage * WeightSpeedModifier));
		// Calculate the health modifier to speed
		HealthMod = ((Health/HealthMax) * HealthSpeedModifier) + (1.0 - HealthSpeedModifier);
		// Apply all the modifiers
		GroundSpeed = default.GroundSpeed * HealthMod;
		GroundSpeed *= WeightMod;
		GroundSpeed += InventorySpeedModifier;
		if ( KFPlayerReplicationInfo(PlayerReplicationInfo) != none && KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none )
		{
			GroundSpeed *= KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill.static.GetMovementSpeedModifier(KFPlayerReplicationInfo(PlayerReplicationInfo),KFGameReplicationInfo(Level.GRI));
		}
		if ( KFPlayerReplicationInfo(PlayerReplicationInfo) != none && KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none )
		{
			GroundSpeed *= class<SRVeterancyTypes>(KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill).static.GetMovementSpeedModifierEx(KFPlayerReplicationInfo(PlayerReplicationInfo),KFWeapon(Weapon),ShieldStrength,Health,true);
		}
	}
}

// Remove Shield Sounds , Randomize for Human Pain sound.

function int ShieldAbsorb(int dam)
{
	local float Interval, damage, Remaining, calcBodyShieldDmgReduce;
		local class<SRVeterancyTypes> CurrentPlayerVeterancy;
	//local int PainSound;
	damage = dam;
	if ( ShieldStrength == 0 )
		return damage;
	if (KFPlayerReplicationInfo(PlayerReplicationInfo) != none && 
		KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none 
		)
		CurrentPlayerVeterancy = class<SRVeterancyTypes>(KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill);
	if ( CurrentPlayerVeterancy != none )
	{
		calcBodyShieldDmgReduce = CurrentPlayerVeterancy.static.GetBodyArmorDamageModifierEx(KFPlayerReplicationInfo(PlayerReplicationInfo),KFWeapon(Weapon),Health);
		//Log("ShieldAbsorb"@calcBodyShieldDmgReduce@KFWeapon(Weapon));
		if (calcBodyShieldDmgReduce == 1.0)
			calcBodyShieldDmgReduce = CurrentPlayerVeterancy.static.GetBodyArmorDamageModifier(KFPlayerReplicationInfo(PlayerReplicationInfo));
		damage *= calcBodyShieldDmgReduce;
	}
	// Super.ShieldAbsorb(dam);
	//SetOverlayMaterial( ShieldHitMat, ShieldHitMatTime, False );
	// Randomize Painsounds on Armor hit
//	PainSound = rand(6);
//	if (PainSound == 0)
//		PlaySound(sound'KFPlayerSound.hpain3', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 1)
//		PlaySound(sound'KFPlayerSound.hpain2', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 2)
//		PlaySound(sound'KFPlayerSound.hpain1', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 3)
//		PlaySound(sound'KFPlayerSound.hpain3', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 4)
//		PlaySound(sound'KFPlayerSound.hpain2', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 5)
//		PlaySound(sound'KFPlayerSound.hpain1', SLOT_Pain,2*TransientSoundVolume,,400);

	if ( ShieldStrength > SmallShieldStrength )
	{
		Interval = ShieldStrength - SmallShieldStrength;
		if ( Interval >= 0.75 * damage )
		{
			ShieldStrength -= 0.75 * damage;
			if ( ShieldStrength < SmallShieldStrength )
				SmallShieldStrength = ShieldStrength;
			return (0.25 * Damage);
		}
		else
		{
			ShieldStrength = SmallShieldStrength;
			damage -= Interval;
			Remaining = 0.33 * Interval;
			if ( Remaining <= damage )
				return damage;
			damage -= Remaining;
		}
	}

	if ( ShieldStrength >= 0.5 * damage )
	{
		ShieldStrength -= damage ;
		SmallShieldStrength = ShieldStrength;
		return Remaining + (0.25 * damage);   // 0.5
	}
	else
	{
		damage -= ShieldStrength;
		ShieldStrength = 0;
		SmallShieldStrength = 0;
	}
	return damage + Remaining;
}


function int EmulateShieldAbsorb(int dam)
{
	local float Interval, damage, Remaining, calcBodyShieldDmgReduce;
	local class<SRVeterancyTypes> CurrentPlayerVeterancy;
	local int EmuShieldStrength, EmuSmallShieldStrength;
	//local int PainSound;
	EmuSmallShieldStrength=SmallShieldStrength;
	EmuShieldStrength=ShieldStrength;
	damage = dam;
	if ( EmuShieldStrength == 0 )
		return damage;
	if (KFPlayerReplicationInfo(PlayerReplicationInfo) != none && 
		KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none 
		)
		CurrentPlayerVeterancy = class<SRVeterancyTypes>(KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill);
	if ( CurrentPlayerVeterancy != none )
	{
		calcBodyShieldDmgReduce = CurrentPlayerVeterancy.static.GetBodyArmorDamageModifierEx(KFPlayerReplicationInfo(PlayerReplicationInfo),KFWeapon(Weapon),Health);
		//Log("ShieldAbsorb"@calcBodyShieldDmgReduce@KFWeapon(Weapon));
		if (calcBodyShieldDmgReduce == 1.0)
			calcBodyShieldDmgReduce = CurrentPlayerVeterancy.static.GetBodyArmorDamageModifier(KFPlayerReplicationInfo(PlayerReplicationInfo));
		damage *= calcBodyShieldDmgReduce;
	}
	// Super.ShieldAbsorb(dam);
	//SetOverlayMaterial( ShieldHitMat, ShieldHitMatTime, False );
	// Randomize Painsounds on Armor hit
//	PainSound = rand(6);
//	if (PainSound == 0)
//		PlaySound(sound'KFPlayerSound.hpain3', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 1)
//		PlaySound(sound'KFPlayerSound.hpain2', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 2)
//		PlaySound(sound'KFPlayerSound.hpain1', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 3)
//		PlaySound(sound'KFPlayerSound.hpain3', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 4)
//		PlaySound(sound'KFPlayerSound.hpain2', SLOT_Pain,2*TransientSoundVolume,,400);
//	else if (PainSound == 5)
//		PlaySound(sound'KFPlayerSound.hpain1', SLOT_Pain,2*TransientSoundVolume,,400);

	if ( EmuShieldStrength > EmuSmallShieldStrength )
	{
		Interval = EmuShieldStrength - EmuSmallShieldStrength;
		if ( Interval >= 0.75 * damage )
		{
			EmuShieldStrength -= 0.75 * damage;
			if ( EmuShieldStrength < EmuSmallShieldStrength )
				EmuSmallShieldStrength = EmuShieldStrength;
			return (0.25 * Damage);
		}
		else
		{
			EmuShieldStrength = EmuSmallShieldStrength;
			damage -= Interval;
			Remaining = 0.33 * Interval;
			if ( Remaining <= damage )
				return damage;
			damage -= Remaining;
		}
	}

	if ( EmuShieldStrength >= 0.5 * damage )
	{
		EmuShieldStrength -= damage ;
		EmuSmallShieldStrength = EmuShieldStrength;
		return Remaining + (0.25 * damage);   // 0.5
	}
	else
	{
		damage -= EmuShieldStrength;
		EmuShieldStrength = 0;
		EmuSmallShieldStrength = 0;
	}
	return damage + Remaining;
}

function int ShowStalkersEx()
{
	if ( KFPlayerReplicationInfo(PlayerReplicationInfo) != none && KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill != none )
	{
		return class<SRVeterancyTypes>(KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill).Static.ShowStalkersEx(KFPlayerReplicationInfo(PlayerReplicationInfo),KFWeapon(Weapon),ShieldStrength,Health);
	}
	return 0;
}

function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
	local Vector			TossVel;
	local Trigger			T;
	local NavigationPoint	N;
	local PlayerDeathMark	D;
	local Projectile		PP;
	local FakePlayerPawn	FP;
	local string 			MSg;

	if ( bDeleteMe || Level.bLevelChange || Level.Game == None )
		return; // already destroyed, or level is being cleaned up

	if ( DamageType.default.bCausedByWorld && (Killer == None || Killer == Controller) && LastHitBy != None )
		Killer = LastHitBy;

	// mutator hook to prevent deaths
	// WARNING - don't prevent bot suicides - they suicide when really needed
	if ( Level.Game.PreventDeath(self, Killer, damageType, HitLocation) )
	{
		Health = max(Health, 1); //mutator should set this higher
		return;
	}

	// Turn off the auxilary collision when the player dies
	if (  AuxCollisionCylinder != none )
	{
		AuxCollisionCylinder.SetCollision(False,False,False);
	}

	// Hack fix for team-killing.
	if( KFPlayerReplicationInfo(PlayerReplicationInfo)!=None )
	{
		FP = KFPlayerReplicationInfo(PlayerReplicationInfo).GetBlamePawn();
		if( FP!=None )
		{
			foreach DynamicActors(Class'Projectile',PP)
			{
				if( PP.Instigator==Self )
					PP.Instigator = FP;
			}
		}
	}

	D = Spawn(Class'PlayerDeathMark');
	if( D!=None )
		D.Velocity = Velocity;

	Health = Min(0, Health);

	if ( Weapon != None && (DrivenVehicle == None || DrivenVehicle.bAllowWeaponToss) )
	{
		if ( Controller != None )
			Controller.LastPawnWeapon = Weapon.Class;
		Weapon.HolderDied();
		TossVel = Vector(GetViewRotation());
		TossVel = TossVel * ((Velocity Dot TossVel) + 500) + Vect(0,0,200);
		TossWeapon(TossVel);
	}
	if ( DrivenVehicle != None )
	{
		Velocity = DrivenVehicle.Velocity;
		DrivenVehicle.DriverDied();
	}

	if ( Controller != None )
	{
		if (Controller.bGodMode)
		{
			Controller.bGodMode = False;
			Msg = "You've died while being in god mode - you are no longer immortal!";
			Msg = right(Msg,len(Msg)-1);
			if ( PlayerController(Controller) != none )
			{
				PlayerController(Controller).ClearProgressMessages();
				PlayerController(Controller).SetProgressTime(6);
				PlayerController(Controller).SetProgressMessage(0, Msg, class'Canvas'.Static.MakeColor(255,255,255));
			}
		}
		Controller.WasKilledBy(Killer);
		Level.Game.Killed(Killer, Controller, self, damageType);
	}
	else Level.Game.Killed(Killer, Controller(Owner), self, damageType);
	DrivenVehicle = None;
	if ( Killer != None )
		TriggerEvent(Event, self, Killer.Pawn);
	else TriggerEvent(Event, self, None);
	// make sure to untrigger any triggers requiring player touch
	if ( IsPlayerPawn() || WasPlayerPawn() )
	{
		PhysicsVolume.PlayerPawnDiedInVolume(self);
		foreach TouchingActors(class'Trigger',T)
			T.PlayerToucherDied(self);
		// event for HoldObjectives
		foreach TouchingActors(class'NavigationPoint', N)
			if ( N.bReceivePlayerToucherDiedNotify )
				N.PlayerToucherDied( Self );
	}
	// remove powerup effects, etc.
	RemovePowerups();
	Velocity.Z *= 1.3;
	if ( IsHumanControlled() )
		PlayerController(Controller).ForceDeathUpdate();
	NetUpdateFrequency = Default.NetUpdateFrequency;
	PlayDying(DamageType, HitLocation);
	if ( !bPhysicsAnimUpdate && !IsLocallyControlled() )
		ClientDying(DamageType, HitLocation);
}

/* Overriden to resolve issue turning flashlight with Dual MK23 */
simulated exec function ToggleFlashlight()
{
	local KFWeapon KFWeap;

	if ( Controller == none )
	{
		return;
	}

	if ( KFWeapon(Weapon) != none && KFWeapon(Weapon).bTorchEnabled )
	{
		Weapon.ClientStartFire(1);
	}
	else
	{
		KFWeap = KFWeapon(FindInventoryType(class'ShotgunW'));
		if ( KFWeap == none )
		{
			KFWeap = KFWeapon(FindInventoryType(class'DualiesW'));
			if ( KFWeap == none || DualDeagle(KFWeap) != none || DualMK23W(KFWeap) != none ||
				DualDeagleW(KFWeap) != none ||
				DualFlareRevolver(KFWeap) != none
				)
			{
				KFWeap = KFWeapon(FindInventoryType(class'SingleW'));
			}
		}

		if ( KFWeap != none )
		{
			KFWeap.bPendingFlashlight = true;

			PendingWeapon = KFWeap;

			if ( Weapon != none )
			{
				Weapon.PutDown();
			}
			else
			{
				ChangedWeapon();
			}
		}
	}
}

simulated function HandleNadeThrowAnim()
{
	if( Weapon != none )
	{
		if( AK47AssaultRifle(Weapon) != none || AK47W(Weapon) != none )
		{
			SetAnimAction('Frag_AK47');
		}
		else if( Bullpup(Weapon) != none || BullpupW(Weapon) != none )
		{
			SetAnimAction('Frag_Bullpup');
		}
		else if( Crossbow(Weapon) != none || CrossbowW(Weapon) != none || SCrossbowW(Weapon) != none )
		{
			SetAnimAction('Frag_Crossbow');
		}
		else if(	Deagle(Weapon) != none || DeagleW(Weapon) != none || 
					MK23W(Weapon) != none)
		{
			SetAnimAction('Frag_Single9mm');
		}
		else if( Dualies(Weapon) != none || DualiesW(Weapon) != none )
		{
			SetAnimAction('Frag_Dual9mm');
		}
		else if( FlareRevolver(Weapon) != none || DualFlareRevolver(Weapon) != none )
		{
			SetAnimAction('Frag_Dual9mm');
		}
		else if(	DualDeagle(Weapon) != none || DualDeagleW(Weapon) != none || 
					DualMK23W(Weapon) != none)
		{
			SetAnimAction('Frag_Dual9mm');
		}
		else if( FlameThrower(Weapon) != none || FlameThrowerW(Weapon) != none || SFlameThrowerW(Weapon) != none)
		{
			SetAnimAction('Frag_Flamethrower');
		}
		else if( 	Axe(Weapon) != none || AxeW(Weapon) != none || 
					FireAxeW(Weapon) != none || BanHammerW(Weapon) != none)
		{
			SetAnimAction('Frag_Axe');
		}
		else if( Chainsaw(Weapon) != none || ChainsawW(Weapon) != none || SChainsawW(Weapon) != none )
		{
			SetAnimAction('Frag_Chainsaw');
		}
		else if( Katana(Weapon) != none || KatanaW(Weapon) != none || SKatanaW(Weapon) != none || RaijinW(Weapon) != none )
		{
			SetAnimAction('Frag_Katana');
		}
		else if( Knife(Weapon) != none )
		{
			SetAnimAction('Frag_Knife');
		}
		else if( Machete(Weapon) != none || MacheteW(Weapon) != none )
		{
			SetAnimAction('Frag_Knife');
		}
		else if( 	Syringe(Weapon) != none || SyringeW(Weapon) != none  || 
					AdrenalineSyringeW(Weapon) != none || LethalInjectionW(Weapon) != none )
		{
			SetAnimAction('Frag_Syringe');
		}
		else if( Welder(Weapon) != none || WelderW(Weapon) != none || SWelderW(Weapon) != none )
		{
			SetAnimAction('Frag_Syringe');
		}
		else if( 	BoomStick(Weapon) != none || BoomStickW(Weapon) != none || 
					SBoomStickW(Weapon) != none )
		{
			SetAnimAction('Frag_HuntingShotgun');
		}
		else if( LAW(Weapon) != none || LAWW(Weapon) != none )
		{
			SetAnimAction('Frag_LAW');
		}
		else if( Shotgun(Weapon) != none || ShotgunW(Weapon) != none || SShotgunW(Weapon) != none )
		{
			SetAnimAction('Frag_Shotgun');
		}
		else if( Winchester(Weapon) != none || WinchesterW(Weapon) != none )
		{
			SetAnimAction('Frag_Winchester');
		}
		else if( Single(Weapon) != none || SingleW(Weapon) != none )
		{
			SetAnimAction('Frag_Single9mm');
		}
		else if( M14EBRBattleRifle(Weapon) != none || M14W(Weapon) != none )
		{
			SetAnimAction('Frag_M14');
		}
		else if(	SCARMK17AssaultRifle(Weapon) != none || 
					SCAR17W(Weapon) != none || SCAR19W(Weapon) != none )
		{
			SetAnimAction('Frag_SCAR');
		}
		else if( 	AA12AutoShotgun(Weapon) != none || AA12W(Weapon) != none ||
					AFS12W(Weapon) != none)
		{
			SetAnimAction('Frag_AA12');
		}
		else if( 	MP7MMedicGun(Weapon) != none || MP7MW(Weapon) != none || 
					MP7M2W(Weapon) != none || M7A3MW(Weapon) != none ||
					AcidGunW(Weapon) != none
				)
		{
			SetAnimAction('Frag_MP7');
		}
		else if( 	PipeBombExplosive(Weapon) != none || PipeBombW(Weapon) != none ||
					BigPipeBombW(Weapon) != none || VeryBigPipeBombW(Weapon) != none ||
					SelfDestructW(Weapon) != none ||  FFPipeBombW(Weapon) != none )
		{
			SetAnimAction('Frag_PipeBomb');
		}
		else if( 	M79GrenadeLauncher(Weapon) != none || M79FlameW(Weapon) != none ||
					M79W(Weapon) != none
				)
		{
			SetAnimAction('Frag_M79');
		}
		else if( 	M32GrenadeLauncher(Weapon) != none || M32W(Weapon) != none ||
					M56W(Weapon) != none)
		{
			SetAnimAction('Frag_M32_MGL');
		}
	}
	else
	{
		SetAnimAction('Frag_Knife');
	}
}

/* function bool AddInventory( inventory NewItem )
{
	Log("SRKFHumanPawn.AddInventory");
	Super.AddInventory( NewItem );
}
 */
/* 
 function Inventory FindInventoryType( class DesiredClass )
{
	local Inventory Inv;
	local int Count;

	//Log("FindInventoryType");
	for( Inv=Inventory; Inv!=None && Count < 1000; Inv=Inv.Inventory )
	{
		//Log("FindInventoryType"@DesiredClass@Inv);
		if ( Inv.class == DesiredClass )
		{
			return Inv;
		}
		Count++;
	}

	// Search for subclasses if exact class wasn't found
	Count = 0;
	for ( Inv = Inventory; Inv != None && Count < 1000; Inv = Inv.Inventory )
	{
		//Log("FindInventoryType2"@DesiredClass@Inv);
		if ( ClassIsChildOf(Inv.Class, DesiredClass) )
			return Inv;
		Count++;
	}

	return None;
}
 */
 
simulated function TakeDamage( int Damage, Pawn InstigatedBy, Vector Hitlocation, Vector Momentum, class<DamageType> damageType, optional int HitIndex)
{
	if(InstigatedBy!=None && InstigatedBy.IsA('KFHumanPawn') && Damage>0 && Role < ROLE_Authority)
	{
		Log("You were injured by"@InstigatedBy.OwnerName@"("$Damage$")");
	}
	Super.TakeDamage(Damage, InstigatedBy, Hitlocation, Momentum, DamageType);
}

defaultproperties
{
     RequiredEquipment(0)="PerksSimHostOrg.KnifeW"
     RequiredEquipment(1)="PerksSimHostOrg.SingleW"
}
